<?php
/**
 * class App_Form_Place_Search
 * common restaurant search form
 *
 */
class App_Form_Place_Search extends Zend_Form
{
    /**
     * init the form
     *
     * @return object
     */
    public function init()
    {
        $this->setMethod('post');

        // restaurant name
        $this->addElement('text', 'name', array(
            'label'         => 'Restaurant name:',
            'filters'       => array('StringTrim')
        ));

        // rating of restaurant
        $this->addElement('select', 'rating', array(
            'required'  => false,
            'label'     => 'DINE.com Stars:',
            'multiOptions' => array(
                '1' => 'Any',
                '2' => '4 or higher',
                '3' => '3.5 or higher',
                '4' => '3 or higher',
                '5' => '2.5 or higher'
            )
        ));

        // review words
        $this->addElement('text', 'review_words', array(
            'label'         => 'Review Words:',
            'filters'       => array('StringTrim')
        ));

        // review words
        $this->addElement('text', 'review_words', array(
            'label'         => 'Review Words:',
            'filters'       => array('StringTrim')
        ));

        // food
        $food = new App_Model_Food();
        $foods = $food->listAll();
        $this->addElement('select', 'food', array(
            'required'      => false,
            'label'         => 'Restaurant Type:',
            'multiOptions'  => $foods
        ));

        // Add state element
        $this->addElement('select', 'state_id', array(
            'required'  => false,
            'label'     => 'State:',
            // should be set to false when using ajax
            'registerInArrayValidator' => false,
            'multiOptions' => array('0' => ' --- ')
        ));
        // Add city element
        $this->addElement('text', 'city', array(
            'required'  => false,
            'label'     => 'City:',
            'filters'   => array('StringTrim')
        ));

        // Add zip element
        $this->addElement('text', 'zip', array(
            'required'  => false,
            'label'     => 'Zip Code:',
            'filters'   => array('StringTrim')
        ));

        $this->addElement('select', 'distance', array(
            'required'  => false,
            'label'     => 'Distance:',
            'multiOptions' => array(
                '1' => 'Only in this zipcode',
                '2' => 'Within 3 miles of this zip',
                '3' => 'Within 5 miles of this zip',
                '4' => 'Within 10 miles of this zip',
            )
        ));

        $this->addElement('select', 'result_limit', array(
            'required'  => false,
            'label'     => 'Show:',
            'multiOptions' => array(
                '1' => '10 results',
                '2' => '15 results',
                '3' => '20 results',
            )
        ));

        // Add the submit button
        $this->addElement('submit', 'submit', array(
            'ignore'    => true,
            'style'     => 'height:25px',
            'label'     => 'SEARCH',
        ));

        // Add the submit button
        $this->addElement('reset', 'reset', array(
            'ignore'    => true,
            'style'     => 'height:25px',
            'label'     => 'RESET',
        ));

        // And finally add some CSRF protection
        //$this->addElement('hash', 'csrf', array('ignore' => true));
    }
}